<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./hammer.js"></script>
    <style>
        .box{
            width: 100px;
            height: 100px;
            background-color: red;
            position: absolute;
            left: 50%;
            top: 50%;
            z-index: 1000;
            transform: translate(-50%, -50%);
            opacity: 0.3;
        }
        button{
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <button>按钮</button>

    <script>
        //pan:手指按下，并拖拽
        

        let box = document.querySelector('.box');
        let btn = document.querySelector('button');
        
        let hammertime = new Hammer(box);

        box.addEventListener("touchstart",function(){
            console.log("取消遮罩层");
            box.style.opacity = 0;
            box.addEventListener("transitionend",function(){
                box.style.display = "none";
            })

        })

        btn.addEventListener("click",function(){
            console.log("我被触发了");
        })

        //pan 鼠标拖动事件
        hammertime.on("pan",function(e){
            console.log(e);
        })
    </script>
</body>
</html>